home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // $RCSfile: renderCreateNode.mel $
- // $Revision: /main/10 $
- // $Date: 2000/02/25 13:50:29 $
- //
- // Alias|Wavefront Script File MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 20 August 1996
- // Author: sw, cdt
- //
- // Procedure Name:
- // createRenderNode
- //
- // Description:
- // Procedure to popup the render creation window.
- //
- // Input Arguments:
- // A flag specifying which types of render nodes to create.
- // Currently "-all", "-allWithTexturesUp", "-allWithShadersUp",
- // "-allWithLightsUp", "-textures", "-shadersSG", "-shaders",
- // "-lights", "-utilities" are supported.
- //
- // The command to run after the a node has been created. The name
- // of the created node will substituted "%node" in the command
- // string. If an empty string is passed for the command nothing
- // will be done. Currently the command is only attached to the
- // buttons in the texture tab.
- //
- // If a command is specified the createRenderNode window will be
- // closed.
- //
- // Return Value:
- // None.
- //
- //////////////////////////////////////////////////////////////////////
- //
- // Procedure Name:
- // createRenderNodeCB
- //
- // Description:
- // Procedure to create the node classified as specifed by the inputs
- //
- // Input Arguments:
- // $as -
- // A flag specifying which how to classify the node created.
- // Choices:
- // -as2DTexture : 2d textures
- // -as3DTexture : 3d textures
- // -asEnvTexture : Environment textures
- // -asShader : as a shader
- // -asLight : as a light
- // -asUtility : as a rendering utility node
- //
- // $flag -
- // A secondary flag used to make decisions in combination with $as.
- // Choices:
- // -asNoShadingGroup : for materials; create without a shading group
- // -asDisplacement : for anything; map the created node
- // to a displacement material.
- // -asUtility : for anything; do whatever the $as flag says,
- // but also classify as a utility
- // -asPostProcess : for any postprocess node
- //
- // $type -
- // The type of node to be created.
- //
- // $command -
- // A command entered by the user when invoking createRenderNode.
- // The command will substitute the string %node with the name of the
- // node it creates. createRenderWindow will be closed if a command
- // is not the null string ("").
- //
- // Return Value:
- // None.
- //
-
- global proc string renderCreateNode(
- string $as, string $flag, string $type, string $command,
- int $projection, int $stencil, int $placement, int $shadingGroup,
- int $createAndDrop, string $editor)
- {
- string $node;
- string $cmd;
- string $temp;
- string $image;
- if( $type == "fluidTexture3D" ){
- $placement = false;
- }
- if ($as == "-asTexture") {
-
- $cmd = "shadingNode -asTexture "+$type;
- $node = `evalEcho $cmd`;
- }
- else if ($as == "-as2DTexture") {
-
- if ($projection) {
- $cmd = "shadingNode -asTexture projection";
- $node = `evalEcho $cmd`;
-
- $cmd = "shadingNode -asTexture "+$type;
- $image = `evalEcho $cmd`;
-
- $cmd = "shadingNode -asUtility place3dTexture";
- string $place3d = `evalEcho $cmd`;
-
- $cmd = ("connectAttr "+$place3d+".wim[0] "+$node+".pm");
- evalEcho $cmd;
-
- $cmd = ("connectAttr "+$image+".outColor "+$node+".image");
- evalEcho $cmd;
-
- if ($placement) {
- $cmd = "shadingNode -asUtility place2dTexture";
- string $place2d = `evalEcho $cmd`;
-
- // Correct #repeats for certain 2d textures
- if ($type == "checker" || $type == "bulge" ||
- $type == "cloth" || $type == "grid") {
- setAttr ($place2d + ".repeatU") 4;
- setAttr ($place2d + ".repeatV") 4;
- } else if ($type == "file") {
- fileTexturePlacementConnect $image $place2d;
- }
- $cmd = ("connectAttr "+$place2d+".outUV "+$image+".uv");
- evalEcho $cmd;
- $cmd = ("connectAttr "+$place2d+".outUvFilterSize "+$image+".uvFilterSize");
- evalEcho $cmd;
- }
- }
- else if ($stencil) {
- $cmd = "shadingNode -asUtility stencil";
- $node = `evalEcho $cmd`;
-
- $cmd = "shadingNode -asTexture "+$type;
- $image = `evalEcho $cmd`;
-
- $cmd = ("connectAttr "+$image+".outColor "+$node+".image");
- evalEcho $cmd;
-
- if ($placement) {
- $cmd = "shadingNode -asUtility place2dTexture";
- string $place2d = `evalEcho $cmd`;
-
- $cmd = "shadingNode -asUtility place2dTexture";
- string $placeStencil = `evalEcho $cmd`;
-
- // Correct #repeats for certain 2d textures
- if ($type == "checker" || $type == "bulge" ||
- $type == "cloth" || $type == "grid") {
- setAttr ($place2d + ".repeatU") 4;
- setAttr ($place2d + ".repeatV") 4;
- }
- else if ($type == "file") {
- // special connections for file texture
- fileTexturePlacementConnect $image $place2d;
- }
- // connect texture placement
- $cmd = ("connectAttr "+$place2d+".outUV "+$image+".uv");
- evalEcho $cmd;
- $cmd = ("connectAttr "+$place2d+".outUvFilterSize "+$image+".uvFilterSize");
- evalEcho $cmd;
- $cmd = ("connectAttr "+$placeStencil+".outUV "+$node+".uv");
- evalEcho $cmd;
- $cmd = ("connectAttr "+$placeStencil+".outUvFilterSize "+$node+".uvFilterSize");
- evalEcho $cmd;
- // redefine UV space for input texture
- $cmd = ("connectAttr "+$placeStencil+".outUV "+$place2d+".uv");
- evalEcho $cmd;
- $cmd = ("connectAttr "+$placeStencil+".outUvFilterSize "+$place2d+".uvFilterSize");
- evalEcho $cmd;
- }
- }
- else {
- $cmd = "shadingNode -asTexture "+$type;
- $node = `evalEcho $cmd`;
- $image = $node;
-
- if ($placement) {
- $cmd = "shadingNode -asUtility place2dTexture";
- string $place2d = `evalEcho $cmd`;
-
- // Correct #repeats for certain 2d textures
- if ($type == "checker" || $type == "bulge" ||
- $type == "cloth" || $type == "grid") {
- setAttr ($place2d + ".repeatU") 4;
- setAttr ($place2d + ".repeatV") 4;
- } else if ($type == "file") {
- fileTexturePlacementConnect $node $place2d;
- }
- $cmd = ("connectAttr "+$place2d+".outUV "+$node+".uv");
- evalEcho $cmd;
- $cmd = ("connectAttr "+$place2d+".outUvFilterSize "+$node+".uvFilterSize");
- evalEcho $cmd;
- }
- }
- }
- else if ($as == "-as3DTexture") {
- // Warning messsage that a projection node will not be created.
- if ($projection)
- warning "Projection will not be created for solid textures.";
-
- $cmd = "shadingNode -asTexture "+$type;
- $node = `evalEcho $cmd`;
- $image = $node;
-
- if ($placement) {
- $cmd = "shadingNode -asUtility place3dTexture";
- string $place3d = `evalEcho $cmd`;
-
- $cmd = ("connectAttr "+$place3d+".wim[0] "+$node+".pm");
- evalEcho $cmd;
- }
- }
- else if ($as == "-asEnvTexture") {
- // Warning messsage that a projection node will not be created.
- if ($projection)
- warning "Projection will not be created for environment textures.";
-
- $cmd = "shadingNode -asTexture "+$type;
- $node = `evalEcho $cmd`;
- $image = $node;
-
- if ($placement) {
- $cmd = "shadingNode -asUtility place3dTexture";
- string $place3d = `evalEcho $cmd`;
-
- // Connect the placement matrix
- $cmd = ("connectAttr "+$place3d+".wim[0] "+$node+".pm");
- evalEcho $cmd;
-
- }
- }
- else if ($as == "-asShader" && $shadingGroup &&
- $flag != "-asNoShadingGroup") {
- $cmd = ("shadingNode " + $as + " " + $type);
- $node = `evalEcho $cmd`;
- $image = $node;
-
- $cmd = "sets -renderable true -noSurfaceShader true -empty -name "+$node+"SG";
- string $group = `evalEcho $cmd`;
-
- if ($type == "displacementShader")
- {
- string $cmd = ("connectAttr -f " + $node + ".displacement " + $group + "." + $flag);
- evalEcho $cmd;
- }
- else
- {
- string $cmd = ("connectAttr -f " + $node + ".outColor " + $group + "." + $flag);
- evalEcho $cmd;
- if( $type == "oceanShader" && $flag == "surfaceShader" ){
- // additionally hook up to displacement
- string $cmd = ("connectAttr -f " + $node + ".displacement " + $group + ".displacementShader");
- evalEcho $cmd;
- $cmd = ("connectAttr -f time1.outTime " + $node + ".time");
- evalEcho $cmd;
- }
- }
- }
- else if ($as == "-asLight")
- {
- $cmd = ("shadingNode " + $as + " " + $type);
- string $parent = `evalEcho $cmd`;
- string $children[] = `listRelatives -children $parent`;
- $node = $children[0];
- $image = $node;
- }
- else {
- $cmd = ("shadingNode " + $as + " " + $type);
- $node = `evalEcho $cmd`;
- $image = $node;
- }
-
- if ($flag == "-asDisplacement") {
- $cmd = "shadingNode -asShader displacementShader";
- string $disp = `evalEcho $cmd`;
-
- $cmd = ("connectAttr " + $node+".outAlpha " + $disp+".displacement");
- evalEcho $cmd;
-
- // now, reassign $node to be the displacement node
- $node=$disp;
- }
- if( ($type == "fluidTexture3D" || $type == "fluidTexture2D" || $type == "fluidShape" ) && size($image) > 0){
-
- $cmd = ("connectAttr time1.outTime " + $image+".currentTime");
- evalEcho $cmd;
- }
-
- select $node;
-
- if ($command != "") {
- $cmd = substitute("%node",$command,$node);
- evalEcho $cmd;
-
- window -e -vis false createRenderNodeWindow;
- }
-
- if($createAndDrop != 0) {
- hyperShade -rcd $node $editor;
- }
-
- return $node;
- }
-